﻿using UnityEngine;
using System.Collections;
using System;
using ProtoBuf.Meta;

namespace ProtoBuf.Serializers
{

    sealed class UnityVector3Serializer : IProtoSerializer
    { 
        static readonly Type expectedType = typeof(Vector3);

        public UnityVector3Serializer(ProtoBuf.Meta.TypeModel model){}

        public Type ExpectedType    {get { return expectedType; } }


        public bool RequiresOldValue
        {
            get { return false; }
        }
        public bool ReturnsValue
        {
            get { return true; }
        }

        public object Read(object value, ProtoReader source)
        {
            Helpers.DebugAssert(value == null); // since replaces
            return BclHelpers.ReadUnityVector3(source);
        } 

        public void Write(object value, ProtoWriter dest)
        {
            BclHelpers.WriteUnityVector3((Vector3)value, dest);
        }
    }


}
